package com.ruoyi.web.controller.laiqianba.source;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.laiqianba.service.IMemberSourceDictInfoService;
import com.ruoyi.web.wrapper.MemberSourceInfoWrapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.SourceMemberDataInfo;
import com.ruoyi.source.service.ISourceMemberDataInfoService;
import com.ruoyi.web.wrapper.SourceMemberDataInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线索用户资质信息Controller
 * 
 * @author ruoyi
 * @date 2023-12-28
 */
@RestController
@RequestMapping("/source/memberData")
public class SourceMemberDataInfoController extends BaseController
{
    @Autowired
    private ISourceMemberDataInfoService sourceMemberDataInfoService;
    @Autowired
    private IMemberSourceDictInfoService memberSourceDictInfoService;

    /**
     * 查询线索用户资质信息列表
     */
    @PreAuthorize("@ss.hasPermi('source:memberData:list')")
    @GetMapping("/list")
    public TableDataInfo list(SourceMemberDataInfo sourceMemberDataInfo)
    {
        startPage();
        List<Map<String, Object>> list = sourceMemberDataInfoService.selectSourceMemberDataInfoMapList(sourceMemberDataInfo);
        Map<String, String> sourceDictMap = memberSourceDictInfoService.selectSourceDictMap();
        list = new SourceMemberDataInfoWrapper(list).setSourceDictMap(sourceDictMap).wrap();
        return getDataTable(list);
    }

    /**
     * 导出线索用户资质信息列表
     */
    @PreAuthorize("@ss.hasPermi('source:memberData:export')")
    @Log(title = "线索用户资质信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SourceMemberDataInfo sourceMemberDataInfo)
    {
        List<SourceMemberDataInfo> list = sourceMemberDataInfoService.selectSourceMemberDataInfoList(sourceMemberDataInfo);
        ExcelUtil<SourceMemberDataInfo> util = new ExcelUtil<SourceMemberDataInfo>(SourceMemberDataInfo.class);
        util.exportExcel(response, list, "线索用户资质信息数据");
    }

    /**
     * 获取线索用户资质信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('source:memberData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sourceMemberDataInfoService.selectSourceMemberDataInfoById(id));
    }

    /**
     * 新增线索用户资质信息
     */
    @PreAuthorize("@ss.hasPermi('source:memberData:add')")
    @Log(title = "线索用户资质信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SourceMemberDataInfo sourceMemberDataInfo)
    {
        return toAjax(sourceMemberDataInfoService.insertSourceMemberDataInfo(sourceMemberDataInfo));
    }

    /**
     * 修改线索用户资质信息
     */
    @PreAuthorize("@ss.hasPermi('source:memberData:edit')")
    @Log(title = "线索用户资质信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SourceMemberDataInfo sourceMemberDataInfo)
    {
        return toAjax(sourceMemberDataInfoService.updateSourceMemberDataInfo(sourceMemberDataInfo));
    }

    /**
     * 删除线索用户资质信息
     */
    @PreAuthorize("@ss.hasPermi('source:memberData:remove')")
    @Log(title = "线索用户资质信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sourceMemberDataInfoService.deleteSourceMemberDataInfoByIds(ids));
    }
}
